/*
 * Copyright 2010 Biz-e (info@biz-e.nl)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.biz_e.site.client;

import java.util.List;

import nl.biz_e.site.shared.models.Content;
import nl.biz_e.site.shared.models.Version;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

/**
 * Defines the RPC methods available for contents
 * 
 * @author Joost A. Bloemsma
 */
@RemoteServiceRelativePath("content")
public interface ContentService extends RemoteService {
	/**
	 * Returns the current active version of the
	 * contents that belongs to the passed id
	 * 
	 * @param key
	 * @return The content
	 */
	public Content getContent(String key);
	
	/**
	 * Returns the specified version of the
	 * contents that belongs to the passed id
	 * 
	 * @param version
	 * @return The content
	 */
	public Content getContent(Version version);
	
	/**
	 * Saves a new content and returns the version number
	 * 
	 * @param content The new content
	 * @param key The key this content belongs to
	 * @return The version number
	 */
	public Version saveContent(Content content, String key);
	
	/**
	 * Returns a {@link List} of all available content keys
	 * 
	 * @return a List
	 */
	public List<String> getAvailableKeys();
	
	/**
	 * Returns a list of all available versions of a particular key
	 * 
	 * @param key
	 * @return a List
	 */
	public List<Version> getAvailableVersions(String key);
	
	/**
	 * Returns the latest version of a particular key
	 * 
	 * @param key
	 * @return the version
	 */
	public Version getLatestVersion(String key);
	
	/**
	 * Returns the current active version of a particular key.<br/>
	 * If there is no active version (or an unknown key is passed) null is
	 * returned.
	 * 
	 * @param key
	 * @return The version
	 */
	public Version getActiveVersion(String key);
	
	/**
	 * Changes the current active version of a particular key.<br/>
	 * This will be the version that will show up when visitors visit the site.
	 * 
	 * @param version
	 * @return the previous active version
	 */
	public Version setActiveVersion(Version version);
	
	/**
	 * Create a new key.
	 * 
	 * @param key
	 */
	public void createKey(String key);
	
}
